package LeetCode;

import java.util.LinkedList;
import java.util.Queue;

public class LC_649_Dota2Senate {

    public static void main(String[] args) {

    }

    class Solution {
        public String predictPartyVictory(String senate) {
            Queue<Integer> radiant = new LinkedList<>();
            Queue<Integer> dire = new LinkedList<>();
            for (int i = 0; i < senate.length(); i++) {
                (senate.charAt(i) == 'R' ? radiant : dire).offer(i);
            }
            while (!radiant.isEmpty() && !dire.isEmpty()) {
                int rIndex = radiant.poll();
                int dIndex = dire.poll();
                if (rIndex < dIndex) {
                    radiant.offer(rIndex + senate.length());
                } else {
                    dire.offer(dIndex + senate.length());
                }
            }
            return radiant.size() > dire.size() ? "Radiant" : "Dire";
        }
    }

}